package com.fhz.kotlinstest.pagingSource

import androidx.paging.PagingSource
import androidx.paging.PagingState

//数据的来源
class Pag3PagingSource : PagingSource<Int,String>(){
    override fun getRefreshKey(state: PagingState<Int, String>): Int? {
        return 100
    }

    override suspend fun load(params: LoadParams<Int>): LoadResult<Int, String> {
        //正经发送网络请求的地方
        val start = params.key ?: 1
        // Load as many items as hinted by params.loadSize
        val range = start.until(start + params.loadSize)

        return LoadResult.Page(
            data = listOf("1", "2", "3", "4", "5", "6", "7", "8", "9", "10"),
            // Make sure we don't try to load items behind the STARTING_KEY
            prevKey = null,
            nextKey = null
        )
    }

}